package com.hisense.hiioc.hismartplate.robot.engine;

import com.hisense.hiioc.hismartplate.constants.RobotConstant;
import com.hisense.hiioc.hismartplate.entity.dto.MesRobot;
import com.hisense.hiioc.hismartplate.robot.factory.CacheFactory;
import com.hisense.hiioc.hismartplate.robot.factory.DirectiveFactory;
import com.hisense.hiioc.hismartplate.utils.EmptyUtils;
import com.hisense.hiioc.hismartplate.utils.UUIDGenerator;

import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * @Auther:biexiande@hisense.com
 * @date:2018/7/3 14:25
 * @des
 */
public class DialogInputHandler extends AbstractInputHandler {

    @Override
    public void doProcess(MesRobot mesRobot,List<String> directiveList, IInputHander nextHandlelr) {
        String input = mesRobot.getText();
        String sessionId=mesRobot.getSessionid();
        if(EmptyUtils.isEmpty(sessionId)){
            nextHandlelr.doProcess(mesRobot,directiveList);
        }else{
            String scene="";
            try {
                scene=(String)CacheFactory.INSTANCE.getCache().get(sessionId);
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
            String token = UUIDGenerator.create32Key();
                switch (scene){
                    case RobotConstant.SCENE_NAVIGATION_NAVIGATE:
                        DirectiveFactory.generateNavigationDirective(directiveList, mesRobot,token, input, sessionId);
                        break;
                    default:
                        nextHandlelr.doProcess(mesRobot,directiveList);
                        break;
                }
            }
    }
}